Typed Array Extensions

require.mx('mxjs/base/utilities/typed_array_extensions.js');

Adds convenience methods to the TypedArray types.

StatusName

Category: library

This library does not return anything (there is no need to save the result of the call to require.mx()). When the library is loaded, it will add methods to the TypedArray prototypes. So, simply require.mx() the library prior to attempting to use any of the extension methods.


Class: TypedArray

A placeholder for all of the builtin TypedArray classes. That is, all of the methods listed for this class are in fact defined for each of the concrete TypedArray classes: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, and Float64Array.

StatusName
Number countIf ( Function callback, Object thisArg )

Count the number of elements in this TypedArray for which a given predicate returns true.

find ( Function callback, Object thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find

findIndex ( Function callback, Object thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex

forEach ( Function callback, Object thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach

String join ( String separator )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join

type map ( Function callback, Object thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map

type mapToType ( Function type, Function callback, Object thisArg )

This is analagous to TypedArray.prototype.map(), except that the type of the returned array is defined by the caller (in the first parameter). This is useful, for example, if you are mapping from an integer array to a float array.

Object minMaxIndices ( )

Find the indices of the minimum and maximum values in this TypedArray.

Object minMaxValues ( )

Find the minimum and maximum values of all elements in this TypedArray.

TypedArray readFromColumn ( Function readFn, Number begin, Number end, Number defaultValue )

This is a static method (it is called directly on the type, not on an object of that type, e.g. Float64Array.readFromColumn(...)).

TypedArray readFromColumnStrict ( Function readFn, Number begin, Number end )

This is a static method (it is called directly on the type, not on an object of that type, e.g. Float64Array.readFromColumn(...)). If any value in the column is missing, this function returns null.

? reduce ( Function callback, Object initialValue )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map

type slice ( Number begin, Number end )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice

transform ( Function ↓callback, Object ↓thisArg )

Transform each element of the TypedArray using the given callback function. This is equivalent to the code:

for (let i = 0; i < array.length; ++i) {
   array[i] = callback.call(thisArg, array[i], i, array);
 }
 

writeToColumn ( Function writeFn, Number offset )

Writes the values in this array to a table column, using the provided write function.

TypedArray.countIf ( callback, thisArg )

Count the number of elements in this TypedArray for which a given predicate returns true.

Parameters:
  • Function callback - the predicate, which receives three parameters: an element value, the index of the element, and this TypedArray; and must return a truthy value if the element should be counted.
  • Object thisArg - (optional) used as this when calling the predicate function.
Returns: Number count - the number of elements for which the predicate returned a truthy value
TypedArray.find ( callback, thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find

Parameters:
TypedArray.findIndex ( callback, thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex

Parameters:
TypedArray.forEach ( callback, thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach

Parameters:
TypedArray.join ( separator )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join

Parameters:
  • String separator - (optional)
Returns: String result
TypedArray.map ( callback, thisArg )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map

Parameters: Returns: type result - an array with the same type as this array, containing the values produced by the callback function.
TypedArray.mapToType ( type, callback, thisArg )

This is analagous to TypedArray.prototype.map(), except that the type of the returned array is defined by the caller (in the first parameter). This is useful, for example, if you are mapping from an integer array to a float array.

Parameters: Returns: type result - an array with type type, containing the values produced by the callback function.
TypedArray.minMaxIndices ( )

Find the indices of the minimum and maximum values in this TypedArray.

Parameters:
Returns: Object results
TypedArray.minMaxValues ( )

Find the minimum and maximum values of all elements in this TypedArray.

Parameters:
Returns: Object results
TypedArray.readFromColumn ( readFn, begin, end, defaultValue )

This is a static method (it is called directly on the type, not on an object of that type, e.g. Float64Array.readFromColumn(...)).

Parameters: Returns: TypedArray values
TypedArray.readFromColumnStrict ( readFn, begin, end )

This is a static method (it is called directly on the type, not on an object of that type, e.g. Float64Array.readFromColumn(...)). If any value in the column is missing, this function returns null.

Parameters: Returns: TypedArray values
TypedArray.reduce ( callback, initialValue )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map

Parameters: Returns: ? result - of the reduction
TypedArray.slice ( begin, end )

This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice

Parameters: Returns: type an - array with the same type as this array
TypedArray.transform ( ↓callback, ↓thisArg )

Transform each element of the TypedArray using the given callback function. This is equivalent to the code:

for (let i = 0; i < array.length; ++i) {
   array[i] = callback.call(thisArg, array[i], i, array);
 }
 

Parameters:
  • Function ↓callback - the callback function, which should receive and return the same type as this array's elements
  • Object ↓thisArg - (optional) used as this when calling the callback function
TypedArray.writeToColumn ( writeFn, offset )

Writes the values in this array to a table column, using the provided write function.

Parameters: